package com.seo.async;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;

public class AsyncTest {

	public static void main(String[] args) throws IOException {
		AsyncSocket asyncSocket = AsyncSocket.create();
		asyncSocket.listen(new InetSocketAddress(8080), 0x100);
		asyncSocket.loop(new AsyncSocketListener() {

			private AsyncSocket asyncSocket;

			@Override
			public void init(AsyncSocket asyncSocket) {
				this.asyncSocket = asyncSocket;
			}

			@Override
			public Object onAccept(SocketChannel socketChannel) throws IOException {
				asyncSocket.subscribe(socketChannel, SelectionKey.OP_READ);
				return null;
			}

			@Override
			public void onRead(SocketChannel socketChannel, Object context) throws IOException {
				// TODO Auto-generated method stub

			}

			@Override
			public void onWrite(SocketChannel socketChannel, Object context) throws IOException {
				// TODO Auto-generated method stub

			}

			@Override
			public void onReadTimeout(SocketChannel socketChannel, Object context) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onWriteTimeout(SocketChannel socketChannel, Object context) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onError(SocketChannel socketChannel, Object context) {
				// TODO Auto-generated method stub

			}

		});
	}
}
